import 'dart:convert';
import 'dart:io';

import 'package:path_provider/path_provider.dart';

import '../util/log_util.dart';

class HistoryInfo{
  late String name;
  late String addr;
  late String status;
  late String dateTime;
  late String msg;
  late int index;

  HistoryInfo(this.index, this.name, this.addr, this.status, this.dateTime, this.msg);

  HistoryInfo.fromOta(this.name, this.addr, this.status, this.msg){
    index = 1;
    DateTime d = DateTime.now();
    dateTime = '${d.year}-${d.month}-${d.day} ${d.hour}:${d.minute}:${d.second}';
  }

  HistoryInfo.fromJson(Map<String, dynamic> json) {
    index = json['index'];
    name = json['name'];
    addr = json['addr'];
    status = json['status'];
    dateTime = json['dateTime'];
    msg = json['msg'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['index'] = index;
    data['name'] = name;
    data['addr'] = addr;
    data['status'] = status;
    data['dateTime'] = dateTime;
    data['msg'] = msg;

    return data;
  }

  @override
  String toString() {
    return 'HistoryInfo{dateTime: $dateTime, name: $name, addr: $addr, status: $status, msg: $msg}';
  }


}